//
//  LiveStreamListView.swift
//  live
//
//  Created by melvyn on 2018/11/23.
//  Copyright © 2018 NEET. All rights reserved.
//

import UIKit
import UICollectionViewLeftAlignedLayout
import SnapKit

class LiveStreamListView: UIView {

    lazy var collectionView: UICollectionView = {
        let collectionView = UICollectionView.init(
            frame: .zero,
            collectionViewLayout: UICollectionViewLeftAlignedLayout.init()
        )
        return collectionView
    }()
    
    lazy var openLiveButton: UIButton = {
        let button = UIButton.init(type: .custom)
        button.setImage(UIImage.init(named: "live_shoot_58x58_"), for: .normal)
        return button
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        addSubview(collectionView)
        addSubview(openLiveButton)
        
        collectionView.snp.makeConstraints { (make) in
            if #available(iOS 11, *) {
                make.top.leading.trailing.equalTo(safeAreaLayoutGuide)
            } else {
                make.top.leading.trailing.equalToSuperview()
            }
            make.bottom.equalToSuperview()
        }
        
        openLiveButton.snp.makeConstraints { (make) in
            if #available(iOS 11, *) {
                make.trailing.equalTo(safeAreaLayoutGuide.snp.trailing).offset(-15)
                make.bottom.equalTo(safeAreaLayoutGuide.snp.bottom).offset(-30)
            } else {
                make.trailing.equalToSuperview().offset(-15)
                make.bottom.equalToSuperview().offset(-30)
            }
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
